<? 
	include('base.php');
	User::protect();
	include_class('releases');
	include_class('band_gps');
	
	$r = Release::get($_REQUEST['id']);
	if ($_GET['task'] == 'select' && !db::isError($r)) {
		$res = $r->selectGuestPerformers($_POST['guest_performer_id']);
		if (!db::isError($res)) { ?>
			<script type="text/javascript">self.close(); opener.location.reload();</script>
		<?
		}
	}

	$page_title = 'Release Guest Performers';
	$stylesheet = 'popup.css';
	include('layout/header_popup.php');
	
	
if (User::isAdmin()) { ?>
	
<?
	if (!db::isError($r)) { 
	
		if (db::isError($res)) {
			$res->outputList();
		}
		
		$selectedGPArray = $r->getReleaseGuestPerformers();
		if (!db::isError($selectedGPArray)) {
			$gpIDArray = array();
			foreach($selectedGPArray as $gp) {
				$gpIDArray[] = $gp->getID();
			}
			unset($selectedGPArray);
			
			$gpArray = BandGuestPerformersList::get_guest_performers(1000,0);
			if (!db::isError($gpArray)) {
			?>
		
				<h1><?=$r->getTitle()?></h1>
				<div class="inset">
				<form id="add_alias" action="<?=$PHP_SELF?>?task=select&amp;id=<?=$_GET['id']?>" method="post">
				<table class="list" border="0" cellspacing="1" cellpadding="0">
				<? foreach($gpArray as $gp) { 
						?>
					<tr>
						<td><input type="checkbox" name="guest_performer_id[]" value="<?=$gp->getID()?>"<? if (in_array($gp->getID(), $gpIDArray)) { ?> checked<? } ?>></td>
						<td style="white-space: nowrap"><?=$gp->getFirstName()?> <?=$gp->getLastName()?></td>
						<td><?=$gp->getFunction()?></td>
					</tr>
				
					<? } ?>	
				</table>
				<br/>
				<input type="submit" value="Select Guest Performers" name="submit" class="button">
				<input type="submit" value="Exit and Close Window" name="exit" onclick="javascript:top.close(); return false" class="button">
				</form>
				</div>
			<? } else { 
			
				$gpArray->outputDialog('Close Window','javascript:self.close()');
				
			}
		
		} else {
		
			$selectedGPArray->outputDialog('Close Window','javascript:self.close()');
			
		}
		
	} else {
	
		$r->outputDialog('Close Window','javascript:self.close()');
			
	}
	
} else { 

	Error::outputDialog('Close Window','javascript:self.close()','Only an administrator may specify this information.');

}

include('layout/footer_popup.php'); ?>
